<template>
    <div class="number">
        <div v-for="item, index in color" :key="index"  @mouseenter="mouseEnter" @mouseleave="mouseLeave">
            <div class="left" :class="{ C1: item.p1 }">
                <i :class="item.icon"></i>
            </div>
            <div class="right">
                <div>{{ item.text }}</div>
                <span>
                    <animate-number :from="start" :to="item.num" duration="1000"></animate-number>
                </span>
            </div>
        </div>
        <!-- <div>
            <div class="left" :class="this.color.p2 ? 'C2' : ''" @mouseenter="mouseEnter">
                <i class="el-icon-reading" :class="this.color.p2 ? 'white' : ''"></i>
            </div>
            <div class="right">
                <div>题目总数</div>
                <span>
                    <animate-number :from="start" :to="end" duration="1000"></animate-number>
                </span>
            </div>
        </div>
        <div>
            <div class="left" :class="this.color.p3 ? 'C3' : ''" @mouseenter="mouseEnter">
                <i class="el-icon-document-copy" :class="this.color.p3 ? 'white' : ''"></i>
            </div>
            <div class="right">
                <div>答卷总数</div>
                <span>
                    <animate-number :from="start" :to="end" duration="1000"></animate-number>
                </span>
            </div>
        </div>
        <div>
            <div class="left" :class="this.color.p4 ? 'C4' : ''" @mouseenter="mouseEnter">
                <i class="el-icon-edit-outline" :class="this.color.p4 ? 'white' : ''"></i>
            </div>
            <div class="right">
                <div>答题总数</div>
                <span>
                    <animate-number :from="start" :to="end" duration="1000"></animate-number>
                </span>
            </div>
        </div> -->
    </div>
</template>
<script>
export default {
    props:[ 'countArr' ],
    data() {
        return {
            color: [{
                p1: false,
                icon: 'el-icon-tickets',
                text: '试卷总数',
                num:14,
            }, {
                p1: false,
                icon: 'el-icon-reading',
                text: '题目总数',
                num:8,
            }, {
                p1: false,
                icon: 'el-icon-document-copy',
                text: '答卷总数',
                num:7,
            }, {
                p1: false,
                icon: 'el-icon-edit-outline',
                text: '答题总数',
                num:9,
            },],
            start: 0,
            end: 10
        }
    },
    methods: {
        mouseEnter(e) {
            let arr = document.querySelectorAll('.number>div');
            let el = e.srcElement;
            this.color.forEach(item => { item.p1 = false })
            arr.forEach((item, index) => {
                if (item == el) {
                    this.color[index].p1 = true;
                }
            })
        },
        mouseLeave() {
            this.color.forEach(item => { item.p1 = false })
        },
    },
    mounted(){
        
    },
    created(){
     
    },
}
</script>
<style lang="scss" scoped>
.number {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    margin: 10px;
    box-sizing: border-box;
    padding: 20px;

    .number::after {
        clear: both;
    }

    >div:nth-child(1) {
        .left.C1 {
            background-color: #40C9C6;
        }

        i {
            color: #40C9C6;
        }
    }

    >div:nth-child(2) {
        .left.C1 {
            background-color: #36A3F7;
        }

        i {
            color: #36A3F7;
        }
    }

    >div:nth-child(3) {
        .left.C1 {
            background-color: #34BFA3;
        }

        i {
            color: #34BFA3;
        }
    }

    >div:nth-child(4) {
        .left.C1 {
            background-color: #F4516C;
        }

        i {
            color: #F4516C;
        }
    }

    >div {
        height: 108px;
        box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
        padding: 10px 20px;
        box-sizing: border-box;
        width: 24%;
        margin-right: 10px;
        color: #666;

        .left.C1 {
            i {
                color: white;
            }
        }

        .left {
            float: left;
            height: calc(108px - 20px);
            width: calc(108px - 20px);
            line-height: 116px;
            border-radius: 10px;
            transition: all 0.3s ease-in;

            i {
                font-size: 60px;
                // color: white;
            }

            text-align: center;
        }

        .right {
            font-weight: 700;
            float: right;
            margin: 26px;
            color: #8C8C8C;
        }
    }
}</style>